const express = require('express');
const current = express.Router();
const MeetingList = require('../model/list')
//当grade是部长时
current.get('/all', (req, res) => {
  MeetingList.find({ status: false }).then(result => res.send({
    code: 200, data: result
  }))
})
//当grade是组长时
current.get('/row', (req, res) => {
  MeetingList.find({ status: false, grade: { $in: ['组长', '普通员工'] } }).then(result => res.send({
    code: 200, data: result
  }))
})
//普通员工
current.get('/index', (req, res) => {
  MeetingList.find({ status: false, grade: { $in: [req.query.grade] } }).then(result => res.send({
    code: 200, data: result
  }))
})
//我的会议
current.post('/mymeeting', (req, res) => {
  MeetingList.find({ status: req.body.status, list: { $in: [req.body.username] } }).then(result => res.send({
    code: 200, data: result
  }))
})
//删除会议
current.post('/delete', (req, res) => {
  MeetingList.findOneAndDelete({ id: req.query.id }).then(result => res.send({
    code: 200, data: result
  }))
})
module.exports = current;